/*
ID: simplyz2
LANG: C
TASK: milk2
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX_LEN 5001
#define Max(a,b) ((a)>(b) ? (a) : (b))
struct Intv {
	int begin, end;
} intvs[MAX_LEN], merge[MAX_LEN];
int num, m_num;

int
compare(const void *arg1, const void *arg2)
{
	return (((struct Intv *)arg1)->begin - ((struct Intv *)arg2)->begin);
}

void
merge_intv()
{
	int i; 
	m_num = 0;
	qsort(intvs, num, sizeof(struct Intv), compare);
	merge[m_num] = intvs[0];
	for(i=1; i<num; i++) {
		if(intvs[i].begin > merge[m_num].end) 
			merge[++m_num] = intvs[i];
		else if(intvs[i].end > merge[m_num].end) 
			merge[m_num].end = intvs[i].end;
	}
}

void
solve()
{
	int i, rt_a, rt_b;
	rt_a = rt_b = 0;
	for(i=0; i<=m_num; i++) {
		rt_a = Max(rt_a, merge[i].end - merge[i].begin);
		if(i)
			rt_b = Max(rt_b, merge[i].begin - merge[i-1].end);
	}
	printf("%d %d\n", rt_a, rt_b);
}

int
main(int argc, char **argv)
{
	int i;
	freopen("milk2.in", "r", stdin);
	freopen("milk2.out", "w", stdout);
	while(scanf("%d", &num) != EOF) {
		for(i=0; i<num; i++)
			scanf("%d %d", &intvs[i].begin, &intvs[i].end);
		merge_intv();
		solve();
	}
	return 0;
}
